#ifndef __SERIAL_DRIVE_H
#define __SERIAL_DRIVE_H
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#include <termios.h>
#include <pthread.h>
#include <string.h>
#include <sys/time.h>
#include <stdlib.h>
#include <stdbool.h>
#define MAXQSIZE 409600  //100k的数据量
#define OK  true
#define ERROR false
typedef  uint8_t QElemType;
typedef  bool Status;
//serial_port.cpp
typedef struct{
      QElemType *base;
      int   front;
      int   rear;
}SqQueue;

int open_serial_port(const char * device, uint32_t baud_rate);
 
// Writes bytes to the serial port, returning 0 on success and -1 on failure.
int write_port(int fd, uint8_t * buffer, size_t size);
 
// Reads bytes from the serial port.
// Returns after all the desired bytes have been read, or if there is a
// timeout or other error.
// Returns the number of bytes successfully read into the buffer, or -1 if
// there was an error reading.
ssize_t read_port(int fd, uint8_t * buffer, size_t size);
Status InitQueue(SqQueue &Q);
int QueueLength(SqQueue &Q);
Status EnQueue(SqQueue &Q,QElemType *e,int num);
Status DeQueue(SqQueue &Q,QElemType &e);
int DeQueue(SqQueue &Q,QElemType *e,int num);
#endif